﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;

namespace Wicresoft.SMS.Web
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class AuthoriseImplementAttribute : Attribute
    {
        private Type _authoriseImplementType;
        public AuthoriseImplementAttribute(Type authoriseImplementType)
        {
            _authoriseImplementType = authoriseImplementType;
        }

        public IAuthorise CreateIAuthoriseImplement()
        {
            if (_authoriseImplementType.GetInterface("IAuthorise") == null)
                throw new Exception("custom IAuthorise is not a implement of IAuthorise");
            IAuthorise authoriseimp = Activator.CreateInstance(_authoriseImplementType) as IAuthorise;
            return authoriseimp;
        }
    }
}